#include "shogicmd.h"
#include "shogierror.h"

ShogiCmd::ShogiCmd()
{
}

bool ShogiCmd::parse(QByteArray* pCommand)
{
	bool bResult = true;
	int j = pCommand->indexOf("=");
	int semi = pCommand->indexOf(";");
	if (j>0)
	{
		m_command = pCommand->left(j);
		m_value = pCommand->mid(j+1,pCommand->size()-j-3);
			qDebug("Received command: %s and value: %s\n",(const char*)m_command.toAscii(),(const char*)m_value.toAscii());
	}
	else
	{
		m_error.setError(ERROR_PARSING_COMMAND);
		bResult = false;
	}
	return bResult;
}

QString ShogiCmd::getValue() const 
{
	return m_value;
}

QString ShogiCmd::getCommand() const 
{
	return m_command;
}

QString ShogiCmd::getCommandAndValue() const 
{ 
	QString k = m_command; 
	k += "=";
	k += m_value; 
	return k;
}
	

void ShogiCmd::setCommandAndValue(QString command, QString value) 
{ 
	m_command = command; 
	m_value = value;
}
	



